package com.chap17.completablefuture;

import lombok.extern.slf4j.Slf4j;

import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * <p>
 * <code>Demo11</code>
 * </p>
 *
 * @author junbao3
 * TODO
 * @date 2023-05-10 10:14
 * Copyright (C) 2021 IFlyTek. All rights reserved.
 */
@Slf4j
public class Demo11 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Void> cf = CompletableFuture.supplyAsync(() -> {
            int number = new Random().nextInt(10);
            log.debug("第一阶段：{}", number);
            return number;
        }).thenAccept(number -> log.debug("第二阶段：" + number * 5));
        log.debug("最终结果：{}",cf.get());
    }
}
